home *** CD-ROM | disk | FTP | other *** search
- global NewR:R,OldR:r,loc1:L,loc2:L
- function dragRect rect1,rect2,rect3,rect4
- put thePort@.portRect.topleft.integerType[1] into portRect1
- put thePort@.portRect.topleft.integerType[2] into portRec2
- put thePort@.portRect.botRight.integerType[1] into portRect3
- put thePort@.portRect.botRight.integerType[2] into portRect4
- setRect oldR,rect1,rect2,rect3,rect4
- put OpenPicture(oldR) into picHndl -- store a handle to the picture
- copyBits thePort@.portbits,thePort@.portbits,oldr,oldr,0,NIL
- closePicture
- put rect3-rect1 into PicWidth
- put rect4-rect2 into PicHeight
- repeat while button()
- put loc1 into loc2
- GetMouse loc1
- if loc1≠loc2 then
- put loc1.integerType[2] into h
- put loc1.integerType[1] into v
- if WithinRect(h,v,portRect1,portRect2,portRect3,portRect4) then -- still in window
- setrect newR,h,v,h+PicWidth,v+PicHeight
- MoveRect picHndl
- put newR.topLeft into oldR.topLeft -- need to do in 4 byte segments for Move.L
- put newr.botRight into oldR.botright
- end if
- end if
- end repeat
- KillPicture pichndl
- return newR.integerType[1] & "," & newR.integerType[2] & "," & newR.integerType[3] & "," & newR.integerType[4]
- invalRect thePort@.portRect -- redraw window
- end dragRect
-
- on MoveRect picHndl -- this does the actual move
- eraseRect oldR
- drawPicture picHndl,newR
- end MoveRect
-
- function WithinRect h,v,r1,r2,r3,r4 -- this is the same as a within in HC
- put h*1 into hh
- put v*1 into vv
- put r1*1 into rr1
- put r2*1 into rr2
- put r3*1 into rr3
- put r4*1 into rr4
- if (hh≥rr1 and vv≥rr2) and (hh≤rr3 and vv≤rr4) then return true
- else return false
- end WithinRect
-